Style Layers
MGLStyleLayer
@interface MGLStyleLayer : NSObject
MGLStyleLayer is an abstract base class for style layers. A style layer
manages the layout and appearance of content at a specific z-index in a style.
An MGLStyle object consists of one or more
MGLStyleLayer objects.
Each style layer defined by the style JSON file is represented at runtime by an
MGLStyleLayer object, which you can use to refine the map’s appearance. You
can also add and remove style layers dynamically.
Create instances of
MGLBackgroundStyleLayer and
the concrete subclasses of
MGLForegroundStyleLayer in
order to use MGLStyleLayer‘s properties and methods.
You do not create instances of MGLStyleLayer directly, and do not
create your own subclasses of this class.
Do not add MGLStyleLayer objects to the style property of a
MGLMapView before
-mapView:didFinishLoadingStyle: is called.
-
identifier
A string that uniquely identifies the style layer in the style to which it is added.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull identifier;Swift
var identifier: String { get }
-
visible
Whether this layer is displayed. A value of
NOhides the layer.Related examples
See the Show and hide a layer example to learn how to toggle an
MGLStyleLayerobject’s visibility.Declaration
Objective-C
@property (nonatomic, getter=isVisible) BOOL visible;Swift
var isVisible: Bool { get set } -
maximumZoomLevel
The maximum zoom level at which the layer gets parsed and appears. This value is a floating-point number.
Declaration
Objective-C
@property (nonatomic) float maximumZoomLevel;Swift
var maximumZoomLevel: Float { get set } -
minimumZoomLevel
The minimum zoom level at which the layer gets parsed and appears. This value is a floating-point number.
Declaration
Objective-C
@property (nonatomic) float minimumZoomLevel;Swift
var minimumZoomLevel: Float { get set }
MGLForegroundStyleLayer
@interface MGLForegroundStyleLayer : MGLStyleLayer
MGLForegroundStyleLayer is an abstract superclass for style layers whose
content is defined by an MGLSource object.
Create instances of
MGLRasterStyleLayer,
MGLHillshadeStyleLayer, and
the
concrete subclasses of
MGLVectorStyleLayer in order to
use
MGLForegroundStyleLayer‘s methods. Do not create instances of
MGLForegroundStyleLayer directly, and do not create your own subclasses of
this class.
Specifying a Style Layer’s Content
-
sourceIdentifier
Identifier of the source from which the receiver obtains the data to style.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *sourceIdentifier;Swift
var sourceIdentifier: String? { get }
MGLBackgroundStyleLayer
@interface MGLBackgroundStyleLayer : MGLStyleLayer
An MGLBackgroundStyleLayer is a style layer that covers the entire map. Use a
background style layer to configure a color or pattern to show below all other
map content. If the style’s other layers use the Mapbox Streets source, the
background style layer is responsible for drawing land, whereas the oceans and
other bodies of water are drawn by
MGLFillStyleLayer objects.
A background style layer is typically the bottommost layer in a style, because
it covers the entire map and can occlude any layers below it. You can therefore
access it by getting the last item in the
MGLStyle.layers
array.
If the background style layer is transparent or omitted from the style, any portion of the map view that does not show another style layer is transparent.
-
-initWithIdentifier:
Returns a background style layer initialized with an identifier.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier;Swift
init(identifier: String)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
Accessing the Paint attribute’s
-
backgroundColor
The color with which the background will be drawn.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
backgroundPatternis set tonil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *backgroundColor;Swift
var backgroundColor: NSExpression! { get set } - Constant
-
backgroundColorTransition
The transition affecting any changes to this layer’s
backgroundColorproperty.This property corresponds to the
background-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition backgroundColorTransition;Swift
var backgroundColorTransition: MGLTransition { get set } -
backgroundOpacity
The opacity at which the background will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *backgroundOpacity;Swift
var backgroundOpacity: NSExpression! { get set } -
backgroundOpacityTransition
The transition affecting any changes to this layer’s
backgroundOpacityproperty.This property corresponds to the
background-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition backgroundOpacityTransition;Swift
var backgroundOpacityTransition: MGLTransition { get set } -
backgroundPattern
Name of image in style images to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512).
You can set this property to an expression containing any of the following:
- Constant string values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *backgroundPattern;Swift
var backgroundPattern: NSExpression! { get set } -
backgroundPatternTransition
The transition affecting any changes to this layer’s
backgroundPatternproperty.This property corresponds to the
background-pattern-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition backgroundPatternTransition;Swift
var backgroundPatternTransition: MGLTransition { get set }
MGLRasterStyleLayer
@interface MGLRasterStyleLayer : MGLForegroundStyleLayer
An MGLRasterStyleLayer is a style layer that renders georeferenced raster
imagery on the map, especially raster tiles.
Use a raster style layer to configure the color parameters of raster tiles
loaded by an MGLRasterTileSource
object or raster images loaded by an
MGLImageSource object. For example,
you could use a raster style layer to
render Mapbox Satellite
imagery, a raster
tile set uploaded to Mapbox Studio, or a raster map authored in TileMill, the classic
Mapbox Editor, or Mapbox Studio Classic.
Raster images may also be used as icons or patterns in a style layer. To
register an image for use as an icon or pattern, use the -[MGLStyle
setImage:forName:] method. To configure a point annotation’s image, use the
MGLAnnotationImage class.
You can access an existing raster style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new raster style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Add an image and Add raster imagery examples to learn how to add imagery with this style layer.
Example
let layer = MGLRasterStyleLayer(identifier: "clouds", source: source)
layer.rasterOpacity = NSExpression(forConstantValue: 0.5)
mapView.style?.addLayer(layer)
-
-initWithIdentifier:source:
Returns a raster style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
-
maximumRasterBrightness
Increase or reduce the brightness of the image. The value is the maximum brightness.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.This attribute corresponds to the
raster-brightness-maxlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *maximumRasterBrightness;Swift
var maximumRasterBrightness: NSExpression! { get set } -
maximumRasterBrightnessTransition
The transition affecting any changes to this layer’s
maximumRasterBrightnessproperty.This property corresponds to the
raster-brightness-max-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition maximumRasterBrightnessTransition;Swift
var maximumRasterBrightnessTransition: MGLTransition { get set } -
minimumRasterBrightness
Increase or reduce the brightness of the image. The value is the minimum brightness.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This attribute corresponds to the
raster-brightness-minlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *minimumRasterBrightness;Swift
var minimumRasterBrightness: NSExpression! { get set } -
minimumRasterBrightnessTransition
The transition affecting any changes to this layer’s
minimumRasterBrightnessproperty.This property corresponds to the
raster-brightness-min-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition minimumRasterBrightnessTransition;Swift
var minimumRasterBrightnessTransition: MGLTransition { get set } -
rasterContrast
Increase or reduce the contrast of the image.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between −1 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *rasterContrast;Swift
var rasterContrast: NSExpression! { get set } -
rasterContrastTransition
The transition affecting any changes to this layer’s
rasterContrastproperty.This property corresponds to the
raster-contrast-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition rasterContrastTransition;Swift
var rasterContrastTransition: MGLTransition { get set } -
rasterFadeDuration
Fade duration when a new tile is added.
This property is measured in milliseconds.
The default value of this property is an expression that evaluates to the float
300. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *rasterFadeDuration;Swift
var rasterFadeDuration: NSExpression! { get set } -
rasterHueRotation
Rotates hues around the color wheel.
This property is measured in degrees.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This attribute corresponds to the
raster-hue-rotatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *rasterHueRotation;Swift
var rasterHueRotation: NSExpression! { get set } -
rasterHueRotationTransition
The transition affecting any changes to this layer’s
rasterHueRotationproperty.This property corresponds to the
raster-hue-rotate-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition rasterHueRotationTransition;Swift
var rasterHueRotationTransition: MGLTransition { get set } -
rasterOpacity
The opacity at which the image will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *rasterOpacity;Swift
var rasterOpacity: NSExpression! { get set } -
rasterOpacityTransition
The transition affecting any changes to this layer’s
rasterOpacityproperty.This property corresponds to the
raster-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition rasterOpacityTransition;Swift
var rasterOpacityTransition: MGLTransition { get set } -
rasterResamplingMode
The resampling/interpolation method to use for overscaling, also known as texture magnification filter
The default value of this property is an expression that evaluates to
linear. Set this property tonilto reset it to the default value.This attribute corresponds to the
raster-resamplinglayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLRasterResamplingModevalues - Any of the following constant string values:
linear: (Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscalednearest: Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *rasterResamplingMode;Swift
var rasterResamplingMode: NSExpression! { get set } - Constant
-
rasterSaturation
Increase or reduce the saturation of the image.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between −1 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *rasterSaturation;Swift
var rasterSaturation: NSExpression! { get set } -
rasterSaturationTransition
The transition affecting any changes to this layer’s
rasterSaturationproperty.This property corresponds to the
raster-saturation-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition rasterSaturationTransition;Swift
var rasterSaturationTransition: MGLTransition { get set }
MGLVectorStyleLayer
@interface MGLVectorStyleLayer : MGLForegroundStyleLayer
MGLVectorStyleLayer is an abstract superclass for style layers whose content
is defined by an MGLShapeSource or
MGLVectorTileSource object.
Create instances of
MGLCircleStyleLayer,
MGLFillStyleLayer,
MGLFillExtrusionStyleLayer,
MGLHeatmapStyleLayer,
MGLLineStyleLayer, and
MGLSymbolStyleLayer in order to
use MGLVectorStyleLayer‘s properties and
methods. Do not create instances of MGLVectorStyleLayer directly, and do not
create your own subclasses of this class.
-
sourceLayerIdentifier
Identifier of the layer within the source identified by the
sourceIdentifierproperty from which the receiver obtains the data to style.Declaration
Objective-C
@property (nonatomic, nullable) NSString *sourceLayerIdentifier;Swift
var sourceLayerIdentifier: String? { get set } -
predicate
The style layer’s predicate.
Use the style layer’s predicate to include only the features in the source layer that satisfy a condition that you define. If the style layer initially comes from the style, its predicate corresponds to the
filterproperty in the style JSON.See the “Predicates and Expressions” guide for details about the predicate syntax supported by this class.
Example
To filter the layer to include only the features whose
indexattribute is 5 or 10 and whoseeleattribute is at least 1,500, you could create anNSCompoundPredicatealong these lines:let layer = MGLLineStyleLayer(identifier: "contour", source: terrain) layer.sourceLayerIdentifier = "contours" layer.predicate = NSPredicate(format: "(index == 5 || index == 10) && CAST(ele, 'NSNumber') >= 1500.0") mapView.style?.addLayer(layer)Declaration
Objective-C
@property (nonatomic, nullable) NSPredicate *predicate;Swift
var predicate: NSPredicate? { get set }
MGLCircleStyleLayer
@interface MGLCircleStyleLayer : MGLVectorStyleLayer
An MGLCircleStyleLayer is a style layer that renders one or more filled
circles on the map.
Use a circle style layer to configure the visual appearance of point or point
collection features. These features can come from vector tiles loaded by an
MGLVectorTileSource object, or
they can be MGLPointAnnotation,
MGLPointFeature,
MGLPointCollection, or
MGLPointCollectionFeature
instances in an MGLShapeSource or
MGLComputedShapeSource object.
A circle style layer renders circles whose radii are measured in screen units.
To display circles on the map whose radii correspond to real-world distances,
use many-sided regular polygons and configure their appearance using an
MGLFillStyleLayer object.
You can access an existing circle style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new circle style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Data-driven circles, Add multiple shapes from a single shape source, and Cluster point data examples to learn how to add circles to your map using this style layer.
Example
let layer = MGLCircleStyleLayer(identifier: "circles", source: population)
layer.sourceLayerIdentifier = "population"
layer.circleColor = NSExpression(forConstantValue: UIColor.green)
let stops = NSExpression(forConstantValue: [12: 2,
22: 180])
layer.circleRadius = NSExpression(forMGLInterpolating: .zoomLevelVariable,
curveType: .exponential,
parameters: NSExpression(forConstantValue: 1.75),
stops: stops)
layer.circleOpacity = NSExpression(forConstantValue: 0.7)
layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married")
mapView.style?.addLayer(layer)
-
initWithIdentifier:source:
Returns a circle style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
-
circleSortKey
Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.
You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleSortKey;Swift
var circleSortKey: NSExpression! { get set }
-
circleBlur
Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleBlur;Swift
var circleBlur: NSExpression! { get set } -
circleBlurTransition
The transition affecting any changes to this layer’s
circleBlurproperty.This property corresponds to the
circle-blur-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleBlurTransition;Swift
var circleBlurTransition: MGLTransition { get set } -
circleColor
The fill color of the circle.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleColor;Swift
var circleColor: NSExpression! { get set } - Constant
-
circleColorTransition
The transition affecting any changes to this layer’s
circleColorproperty.This property corresponds to the
circle-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleColorTransition;Swift
var circleColorTransition: MGLTransition { get set } -
circleOpacity
The opacity at which the circle will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleOpacity;Swift
var circleOpacity: NSExpression! { get set } -
circleOpacityTransition
The transition affecting any changes to this layer’s
circleOpacityproperty.This property corresponds to the
circle-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleOpacityTransition;Swift
var circleOpacityTransition: MGLTransition { get set } -
circlePitchAlignment
Orientation of circle when map is pitched.
The default value of this property is an expression that evaluates to
viewport. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
MGLCirclePitchAlignmentvalues - Any of the following constant string values:
map: The circle is aligned to the plane of the map.viewport: The circle is aligned to the plane of the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circlePitchAlignment;Swift
var circlePitchAlignment: NSExpression! { get set } - Constant
-
circleRadius
Circle radius.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
5. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleRadius;Swift
var circleRadius: NSExpression! { get set } -
circleRadiusTransition
The transition affecting any changes to this layer’s
circleRadiusproperty.This property corresponds to the
circle-radius-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleRadiusTransition;Swift
var circleRadiusTransition: MGLTransition { get set } -
circleScaleAlignment
Controls the scaling behavior of the circle when the map is pitched.
The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This attribute corresponds to the
circle-pitch-scalelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLCircleScaleAlignmentvalues - Any of the following constant string values:
map: Circles are scaled according to their apparent distance to the camera.viewport: Circles are not scaled.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleScaleAlignment;Swift
var circleScaleAlignment: NSExpression! { get set } - Constant
-
circleStrokeColor
The stroke color of the circle.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleStrokeColor;Swift
var circleStrokeColor: NSExpression! { get set } - Constant
-
circleStrokeColorTransition
The transition affecting any changes to this layer’s
circleStrokeColorproperty.This property corresponds to the
circle-stroke-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleStrokeColorTransition;Swift
var circleStrokeColorTransition: MGLTransition { get set } -
circleStrokeOpacity
The opacity of the circle’s stroke.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleStrokeOpacity;Swift
var circleStrokeOpacity: NSExpression! { get set } -
circleStrokeOpacityTransition
The transition affecting any changes to this layer’s
circleStrokeOpacityproperty.This property corresponds to the
circle-stroke-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleStrokeOpacityTransition;Swift
var circleStrokeOpacityTransition: MGLTransition { get set } -
circleStrokeWidth
The width of the circle’s stroke. Strokes are placed outside of the
circleRadius.This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleStrokeWidth;Swift
var circleStrokeWidth: NSExpression! { get set } -
circleStrokeWidthTransition
The transition affecting any changes to this layer’s
circleStrokeWidthproperty.This property corresponds to the
circle-stroke-width-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleStrokeWidthTransition;Swift
var circleStrokeWidthTransition: MGLTransition { get set } -
circleTranslation
The geometry’s offset.
This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 points rightward and 0 points downward. Set this property tonilto reset it to the default value.This attribute corresponds to the
circle-translatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleTranslation;Swift
var circleTranslation: NSExpression! { get set } - Constant
-
circleTranslationTransition
The transition affecting any changes to this layer’s
circleTranslationproperty.This property corresponds to the
circle-translate-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition circleTranslationTransition;Swift
var circleTranslationTransition: MGLTransition { get set } -
circleTranslationAnchor
Controls the frame of reference for
circleTranslation.The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This property is only applied to the style if
circleTranslationis non-nil. Otherwise, it is ignored.This attribute corresponds to the
circle-translate-anchorlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLCircleTranslationAnchorvalues - Any of the following constant string values:
map: The circle is translated relative to the map.viewport: The circle is translated relative to the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *circleTranslationAnchor;Swift
var circleTranslationAnchor: NSExpression! { get set } - Constant
MGLFillStyleLayer
@interface MGLFillStyleLayer : MGLVectorStyleLayer
An MGLFillStyleLayer is a style layer that renders one or more filled (and
optionally stroked) polygons on the map.
Use a fill style layer to configure the visual appearance of polygon or
multipolygon features. These features can come from vector tiles loaded by an
MGLVectorTileSource object, or
they can be MGLPolygon,
MGLPolygonFeature,
MGLMultiPolygon, or
MGLMultiPolygonFeature
instances in an MGLShapeSource
or MGLComputedShapeSource
object.
You can access an existing fill style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new fill style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Select a feature
within a layer example to learn how to use a TERNARY expression to modify
the fillOpacity of an MGLFillStyleLayer object. See the Add a pattern to
a polygon example to learn how to use an image to add pattern to the
features styled by a MGLFillStyleLayer.
Example
let layer = MGLFillStyleLayer(identifier: "parks", source: parks)
layer.sourceLayerIdentifier = "parks"
layer.fillColor = NSExpression(forConstantValue: UIColor.green)
layer.predicate = NSPredicate(format: "type == %@", "national-park")
mapView.style?.addLayer(layer)
-
-initWithIdentifier:source:
Returns a fill style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
-
fillSortKey
Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.
You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillSortKey;Swift
var fillSortKey: NSExpression! { get set }
-
fillAntialiased
Whether or not the fill should be antialiased.
The default value of this property is an expression that evaluates to
YES. Set this property tonilto reset it to the default value.This attribute corresponds to the
fill-antialiaslayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isFillAntialiased, null_resettable) NSExpression *fillAntialiased;Swift
var fillAntialiased: NSExpression! { get set } -
fillColor
The color of the filled part of this layer.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
fillPatternis set tonil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillColor;Swift
var fillColor: NSExpression! { get set } - Constant
-
fillColorTransition
The transition affecting any changes to this layer’s
fillColorproperty.This property corresponds to the
fill-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillColorTransition;Swift
var fillColorTransition: MGLTransition { get set } -
fillOpacity
The opacity of the entire fill layer. In contrast to the
fillColor, this value will also affect the 1pt stroke around the fill, if the stroke is used.The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillOpacity;Swift
var fillOpacity: NSExpression! { get set } -
fillOpacityTransition
The transition affecting any changes to this layer’s
fillOpacityproperty.This property corresponds to the
fill-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillOpacityTransition;Swift
var fillOpacityTransition: MGLTransition { get set } -
fillOutlineColor
The outline color of the fill. Matches the value of
fillColorif unspecified.This property is only applied to the style if
fillPatternis set tonil, andfillAntialiasedis set to an expression that evaluates toYES. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillOutlineColor;Swift
var fillOutlineColor: NSExpression! { get set } - Constant
-
fillOutlineColorTransition
The transition affecting any changes to this layer’s
fillOutlineColorproperty.This property corresponds to the
fill-outline-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillOutlineColorTransition;Swift
var fillOutlineColorTransition: MGLTransition { get set } -
fillPattern
Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.
You can set this property to an expression containing any of the following:
- Constant string values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillPattern;Swift
var fillPattern: NSExpression! { get set } -
fillPatternTransition
The transition affecting any changes to this layer’s
fillPatternproperty.This property corresponds to the
fill-pattern-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillPatternTransition;Swift
var fillPatternTransition: MGLTransition { get set } -
fillTranslation
The geometry’s offset.
This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 points rightward and 0 points downward. Set this property tonilto reset it to the default value.This attribute corresponds to the
fill-translatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillTranslation;Swift
var fillTranslation: NSExpression! { get set } - Constant
-
fillTranslationTransition
The transition affecting any changes to this layer’s
fillTranslationproperty.This property corresponds to the
fill-translate-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillTranslationTransition;Swift
var fillTranslationTransition: MGLTransition { get set } -
fillTranslationAnchor
Controls the frame of reference for
fillTranslation.The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This property is only applied to the style if
fillTranslationis non-nil. Otherwise, it is ignored.This attribute corresponds to the
fill-translate-anchorlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLFillTranslationAnchorvalues - Any of the following constant string values:
map: The fill is translated relative to the map.viewport: The fill is translated relative to the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillTranslationAnchor;Swift
var fillTranslationAnchor: NSExpression! { get set } - Constant
MGLFillExtrusionStyleLayer
@interface MGLFillExtrusionStyleLayer : MGLVectorStyleLayer
An MGLFillExtrusionStyleLayer is a style layer that renders one or more 3D
extruded polygons on the map.
Use a fill-extrusion style layer to configure the visual appearance of polygon
or multipolygon features. These features can come from vector tiles loaded by
an MGLVectorTileSource object, or
they can be MGLPolygon,
MGLPolygonFeature,
MGLMultiPolygon, or
MGLMultiPolygonFeature
instances
in an MGLShapeSource or
MGLComputedShapeSource object.
You can access an existing fill-extrusion style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new fill-extrusion style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Display 3D buildings example to learn how to add and style 3D layers on a map.
Example
let layer = MGLFillExtrusionStyleLayer(identifier: "buildings", source: buildings)
layer.sourceLayerIdentifier = "building"
layer.fillExtrusionHeight = NSExpression(forKeyPath: "height")
layer.fillExtrusionBase = NSExpression(forKeyPath: "min_height")
layer.predicate = NSPredicate(format: "extrude == 'true'")
mapView.style?.addLayer(layer)
-
-initWithIdentifier:source:
Returns a fill-extrusion style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
Accessing the Paint Attributes
-
fillExtrusionBase
The height with which to extrude the base of this layer. Must be less than or equal to
fillExtrusionHeight.This property is measured in meters.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
fillExtrusionHeightis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionBase;Swift
var fillExtrusionBase: NSExpression! { get set } -
fillExtrusionBaseTransition
The transition affecting any changes to this layer’s
fillExtrusionBaseproperty.This property corresponds to the
fill-extrusion-base-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillExtrusionBaseTransition;Swift
var fillExtrusionBaseTransition: MGLTransition { get set } -
fillExtrusionColor
The base color of this layer. The extrusion’s surfaces will be shaded differently based on this color in combination with the
lightsettings. If this color is specified with an alpha component, the alpha component will be ignored; usefillExtrusionOpacityto set layer opacityco.The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
fillExtrusionPatternis set tonil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionColor;Swift
var fillExtrusionColor: NSExpression! { get set } - Constant
-
fillExtrusionColorTransition
The transition affecting any changes to this layer’s
fillExtrusionColorproperty.This property corresponds to the
fill-extrusion-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillExtrusionColorTransition;Swift
var fillExtrusionColorTransition: MGLTransition { get set } -
fillExtrusionHasVerticalGradient
Whether to apply a vertical gradient to the sides of a fill-extrusion layer. If true, sides will be shaded slightly darker farther down.
The default value of this property is an expression that evaluates to
YES. Set this property tonilto reset it to the default value.This attribute corresponds to the
fill-extrusion-vertical-gradientlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionHasVerticalGradient;Swift
var fillExtrusionHasVerticalGradient: NSExpression! { get set } -
fillExtrusionHeight
The height with which to extrude this layer.
This property is measured in meters.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionHeight;Swift
var fillExtrusionHeight: NSExpression! { get set } -
fillExtrusionHeightTransition
The transition affecting any changes to this layer’s
fillExtrusionHeightproperty.This property corresponds to the
fill-extrusion-height-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillExtrusionHeightTransition;Swift
var fillExtrusionHeightTransition: MGLTransition { get set } -
fillExtrusionOpacity
The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionOpacity;Swift
var fillExtrusionOpacity: NSExpression! { get set } -
fillExtrusionOpacityTransition
The transition affecting any changes to this layer’s
fillExtrusionOpacityproperty.This property corresponds to the
fill-extrusion-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillExtrusionOpacityTransition;Swift
var fillExtrusionOpacityTransition: MGLTransition { get set } -
fillExtrusionPattern
Name of image in style images to use for drawing image fill-extrusions. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512).
You can set this property to an expression containing any of the following:
- Constant string values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionPattern;Swift
var fillExtrusionPattern: NSExpression! { get set } -
fillExtrusionPatternTransition
The transition affecting any changes to this layer’s
fillExtrusionPatternproperty.This property corresponds to the
fill-extrusion-pattern-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillExtrusionPatternTransition;Swift
var fillExtrusionPatternTransition: MGLTransition { get set } -
fillExtrusionTranslation
The geometry’s offset.
This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 points rightward and 0 points downward. Set this property tonilto reset it to the default value.This attribute corresponds to the
fill-extrusion-translatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslation;Swift
var fillExtrusionTranslation: NSExpression! { get set } - Constant
-
fillExtrusionTranslationTransition
The transition affecting any changes to this layer’s
fillExtrusionTranslationproperty.This property corresponds to the
fill-extrusion-translate-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition fillExtrusionTranslationTransition;Swift
var fillExtrusionTranslationTransition: MGLTransition { get set } -
fillExtrusionTranslationAnchor
Controls the frame of reference for
fillExtrusionTranslation.The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This property is only applied to the style if
fillExtrusionTranslationis non-nil. Otherwise, it is ignored.This attribute corresponds to the
fill-extrusion-translate-anchorlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLFillExtrusionTranslationAnchorvalues - Any of the following constant string values:
map: The fill extrusion is translated relative to the map.viewport: The fill extrusion is translated relative to the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslationAnchor;Swift
var fillExtrusionTranslationAnchor: NSExpression! { get set } - Constant
MGLHeatmapStyleLayer
@interface MGLHeatmapStyleLayer : MGLVectorStyleLayer
An MGLHeatmapStyleLayer is a style layer that renders a heatmap.
A heatmap visualizes the spatial distribution of a large, dense set of point
data, using color to avoid cluttering the map with individual points at low
zoom levels. The points are weighted by an attribute you specify. Use a heatmap
style layer in conjunction with point or point collection features. These
features can come from vector tiles loaded by an
MGLVectorTileSource object,
or they can be MGLPointAnnotation,
MGLPointFeature,
MGLPointCollection,
or
MGLPointCollectionFeature
instances in an MGLShapeSource or
MGLComputedShapeSource object.
Consider accompanying a heatmap style layer with an
MGLCircleStyleLayer or
MGLSymbolStyleLayer at high zoom
levels. If you are unsure whether the point
data in an MGLShapeSource is dense
enough to warrant a heatmap, you can
alternatively cluster the source using the
MGLShapeSourceOptionClustered
option and render the data using an
MGLCircleStyleLayer or
MGLSymbolStyleLayer.
You can access an existing heatmap style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new heatmap style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Create a heatmap layer example to learn how to add this style layer to your map.
Example
let layer = MGLHeatmapStyleLayer(identifier: "earthquake-heat", source: earthquakes)
layer.heatmapWeight = NSExpression(forMGLInterpolating: .zoomLevelVariable,
curveType: .linear,
parameters: nil,
stops: NSExpression(forConstantValue: [0: 0,
6: 1]))
layer.heatmapIntensity = NSExpression(forMGLInterpolating: .zoomLevelVariable,
curveType: .linear,
parameters: nil,
stops: NSExpression(forConstantValue: [0: 1,
9: 3]))
mapView.style?.addLayer(layer)
-
-initWithIdentifier:source:
Returns a heatmap style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
Accessing the Paint Attributes
-
heatmapColor
The color of each screen point based on its density value in a heatmap. This property is normally set to an interpolation or step expression with the
$heatmapDensityvalue as its input.The default value of this property is an expression that evaluates to a rainbow color scale from blue to red. Set this property to
nilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$heatmapDensityvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *heatmapColor;Swift
var heatmapColor: NSExpression! { get set } - Constant
-
heatmapIntensity
Similar to
heatmapWeightbut controls the intensity of the heatmap globally. Primarily used for adjusting the heatmap based on zoom level.The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *heatmapIntensity;Swift
var heatmapIntensity: NSExpression! { get set } -
heatmapIntensityTransition
The transition affecting any changes to this layer’s
heatmapIntensityproperty.This property corresponds to the
heatmap-intensity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition heatmapIntensityTransition;Swift
var heatmapIntensityTransition: MGLTransition { get set } -
heatmapOpacity
The global opacity at which the heatmap layer will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *heatmapOpacity;Swift
var heatmapOpacity: NSExpression! { get set } -
heatmapOpacityTransition
The transition affecting any changes to this layer’s
heatmapOpacityproperty.This property corresponds to the
heatmap-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition heatmapOpacityTransition;Swift
var heatmapOpacityTransition: MGLTransition { get set } -
heatmapRadius
Radius of influence of one heatmap point in points. Increasing the value makes the heatmap smoother, but less detailed.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
30. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 1
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *heatmapRadius;Swift
var heatmapRadius: NSExpression! { get set } -
heatmapRadiusTransition
The transition affecting any changes to this layer’s
heatmapRadiusproperty.This property corresponds to the
heatmap-radius-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition heatmapRadiusTransition;Swift
var heatmapRadiusTransition: MGLTransition { get set } -
heatmapWeight
A measure of how much an individual point contributes to the heatmap. A value of 10 would be equivalent to having 10 points of weight 1 in the same spot. Especially useful when combined with clustering.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *heatmapWeight;Swift
var heatmapWeight: NSExpression! { get set }
MGLHillshadeStyleLayer
@interface MGLHillshadeStyleLayer : MGLForegroundStyleLayer
An MGLHillshadeStyleLayer is a style layer that renders raster digital elevation
model (DEM) tiles on the map.
Use a hillshade style layer to configure the color parameters of raster tiles
loaded by an
MGLRasterDEMSource
object. For example, you could use a
hillshade style layer to render Mapbox
Terrain-RGB data.
To display posterized hillshading based on vector shapes, as with the Mapbox Terrain
source, use an
MGLVectorTileSource object in
conjunction with several
MGLFillStyleLayer objects.
You can access an existing hillshade style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new hillshade style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Example
let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source)
layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6)
if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") {
mapView.style?.insertLayer(layer, below: canalShadowLayer)
}
-
-initWithIdentifier:source:
Returns a hillshade style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
Accessing the Paint Attributes
-
hillshadeAccentColor
The shading color used to accentuate rugged terrain like sharp cliffs and gorges.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *hillshadeAccentColor;Swift
var hillshadeAccentColor: NSExpression! { get set } - Constant
-
hillshadeAccentColorTransition
The transition affecting any changes to this layer’s
hillshadeAccentColorproperty.This property corresponds to the
hillshade-accent-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition hillshadeAccentColorTransition;Swift
var hillshadeAccentColorTransition: MGLTransition { get set } -
hillshadeExaggeration
Intensity of the hillshade
The default value of this property is an expression that evaluates to the float
0.5. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *hillshadeExaggeration;Swift
var hillshadeExaggeration: NSExpression! { get set } -
hillshadeExaggerationTransition
The transition affecting any changes to this layer’s
hillshadeExaggerationproperty.This property corresponds to the
hillshade-exaggeration-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition hillshadeExaggerationTransition;Swift
var hillshadeExaggerationTransition: MGLTransition { get set } -
hillshadeHighlightColor
The shading color of areas that faces towards the light source.
The default value of this property is an expression that evaluates to
UIColor.whiteColor. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *hillshadeHighlightColor;Swift
var hillshadeHighlightColor: NSExpression! { get set } - Constant
-
hillshadeHighlightColorTransition
The transition affecting any changes to this layer’s
hillshadeHighlightColorproperty.This property corresponds to the
hillshade-highlight-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition hillshadeHighlightColorTransition;Swift
var hillshadeHighlightColorTransition: MGLTransition { get set } -
hillshadeIlluminationAnchor
Direction of light source when map is rotated.
The default value of this property is an expression that evaluates to
viewport. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
MGLHillshadeIlluminationAnchorvalues - Any of the following constant string values:
map: The hillshade illumination is relative to the north direction.viewport: The hillshade illumination is relative to the top of the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationAnchor;Swift
var hillshadeIlluminationAnchor: NSExpression! { get set } - Constant
-
hillshadeIlluminationDirection
The direction of the light source used to generate the hillshading with 0 as the top of the viewport if
hillshadeIlluminationAnchoris set toMGLHillshadeIlluminationAnchorViewportand due north ifhillshadeIlluminationAnchoris set toMGLHillshadeIlluminationAnchorMap.The default value of this property is an expression that evaluates to the float
335. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 359 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationDirection;Swift
var hillshadeIlluminationDirection: NSExpression! { get set } -
hillshadeShadowColor
The shading color of areas that face away from the light source.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *hillshadeShadowColor;Swift
var hillshadeShadowColor: NSExpression! { get set } - Constant
-
hillshadeShadowColorTransition
The transition affecting any changes to this layer’s
hillshadeShadowColorproperty.This property corresponds to the
hillshade-shadow-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition hillshadeShadowColorTransition;Swift
var hillshadeShadowColorTransition: MGLTransition { get set }
MGLLineStyleLayer
@interface MGLLineStyleLayer : MGLVectorStyleLayer
An MGLLineStyleLayer is a style layer that renders one or more stroked
polylines on the map.
Use a line style layer to configure the visual appearance of polyline or
multipolyline features. These features can come from vector tiles loaded by an
MGLVectorTileSource object, or
they can be MGLPolyline,
MGLPolylineFeature,
MGLMultiPolyline, or
MGLMultiPolylineFeature
instances in an MGLShapeSource or
MGLComputedShapeSource object.
You can access an existing line style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new line style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Add multiple
shapes from a single shape source example to learn how to add a line to
your map using this style layer. See the Add a line
style layer from GeoJSON example to learn how to add and style line data to
an MGLMapView object at runtime.
Example
let layer = MGLLineStyleLayer(identifier: "trails-path", source: trails)
layer.sourceLayerIdentifier = "trails"
let stops = NSExpression(forConstantValue: [14: 2,
18: 20])
layer.lineWidth = NSExpression(forMGLInterpolating: .zoomLevelVariable,
curveType: .exponential,
parameters: NSExpression(forConstantValue: 1.5),
stops: stops)
layer.lineColor = NSExpression(forConstantValue: UIColor.brown)
layer.lineCap = NSExpression(forConstantValue: "round")
layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking")
mapView.style?.addLayer(layer)
-
-initWithIdentifier:source:
Returns a line style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
Accessing the Layout Attributes
-
lineCap
The display of line endings.
The default value of this property is an expression that evaluates to
butt. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
MGLLineCapvalues - Any of the following constant string values:
butt: A cap with a squared-off end which is drawn to the exact endpoint of the line.round: A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line’s width and centered on the endpoint of the line.square: A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line’s width.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineCap;Swift
var lineCap: NSExpression! { get set } - Constant
-
lineJoin
The display of lines when joining.
The default value of this property is an expression that evaluates to
miter. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
MGLLineJoinvalues - Any of the following constant string values:
bevel: A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line’s width.round: A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line’s width and centered on the endpoint of the line.miter: A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineJoin;Swift
var lineJoin: NSExpression! { get set } - Constant
-
lineMiterLimit
Used to automatically convert miter joins to bevel joins for sharp angles.
The default value of this property is an expression that evaluates to the float
2. Set this property tonilto reset it to the default value.This property is only applied to the style if
lineJoinis set to an expression that evaluates tomiter. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineMiterLimit;Swift
var lineMiterLimit: NSExpression! { get set } -
lineRoundLimit
Used to automatically convert round joins to miter joins for shallow angles.
The default value of this property is an expression that evaluates to the float
1.05. Set this property tonilto reset it to the default value.This property is only applied to the style if
lineJoinis set to an expression that evaluates toround. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineRoundLimit;Swift
var lineRoundLimit: NSExpression! { get set } -
lineSortKey
Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.
You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineSortKey;Swift
var lineSortKey: NSExpression! { get set }
Accessing the Paint Attributes
-
lineBlur
Blur applied to the line, in points.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineBlur;Swift
var lineBlur: NSExpression! { get set } -
lineBlurTransition
The transition affecting any changes to this layer’s
lineBlurproperty.This property corresponds to the
line-blur-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineBlurTransition;Swift
var lineBlurTransition: MGLTransition { get set } -
lineColor
The color with which the line will be drawn.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
linePatternis set tonil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineColor;Swift
var lineColor: NSExpression! { get set } - Constant
-
lineColorTransition
The transition affecting any changes to this layer’s
lineColorproperty.This property corresponds to the
line-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineColorTransition;Swift
var lineColorTransition: MGLTransition { get set } -
lineDashPattern
Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to points, multiply the length by the current line width. Note that GeoJSON sources with
lineMetrics: truespecified won’t render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels.This property is measured in line widths.
This property is only applied to the style if
linePatternis set tonil. Otherwise, it is ignored.This attribute corresponds to the
line-dasharraylayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant array values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineDashPattern;Swift
var lineDashPattern: NSExpression! { get set } -
lineDashPatternTransition
The transition affecting any changes to this layer’s
lineDashPatternproperty.This property corresponds to the
line-dasharray-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineDashPatternTransition;Swift
var lineDashPatternTransition: MGLTransition { get set } -
lineGapWidth
Draws a line casing outside of a line’s actual path. Value indicates the width of the inner gap.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineGapWidth;Swift
var lineGapWidth: NSExpression! { get set } -
lineGapWidthTransition
The transition affecting any changes to this layer’s
lineGapWidthproperty.This property corresponds to the
line-gap-width-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineGapWidthTransition;Swift
var lineGapWidthTransition: MGLTransition { get set } -
lineGradient
The color gradient with which the line will be drawn. This property only has an effect on lines defined by an
MGLShapeSourcewhoseMGLShapeSourceOptionLineDistanceMetricsoption is set toYES.This property is only applied to the style if
lineDasharrayis set tonil, andlinePatternis set tonil, and the data source requirements are met. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$lineProgressvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineGradient;Swift
var lineGradient: NSExpression! { get set } - Constant
-
lineOffset
The line’s offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineOffset;Swift
var lineOffset: NSExpression! { get set } -
lineOffsetTransition
The transition affecting any changes to this layer’s
lineOffsetproperty.This property corresponds to the
line-offset-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineOffsetTransition;Swift
var lineOffsetTransition: MGLTransition { get set } -
lineOpacity
The opacity at which the line will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineOpacity;Swift
var lineOpacity: NSExpression! { get set } -
lineOpacityTransition
The transition affecting any changes to this layer’s
lineOpacityproperty.This property corresponds to the
line-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineOpacityTransition;Swift
var lineOpacityTransition: MGLTransition { get set } -
linePattern
Name of image in style images to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, …, 512).
You can set this property to an expression containing any of the following:
- Constant string values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *linePattern;Swift
var linePattern: NSExpression! { get set } -
linePatternTransition
The transition affecting any changes to this layer’s
linePatternproperty.This property corresponds to the
line-pattern-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition linePatternTransition;Swift
var linePatternTransition: MGLTransition { get set } -
lineTranslation
The geometry’s offset.
This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 points rightward and 0 points downward. Set this property tonilto reset it to the default value.This attribute corresponds to the
line-translatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineTranslation;Swift
var lineTranslation: NSExpression! { get set } - Constant
-
lineTranslationTransition
The transition affecting any changes to this layer’s
lineTranslationproperty.This property corresponds to the
line-translate-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineTranslationTransition;Swift
var lineTranslationTransition: MGLTransition { get set } -
lineTranslationAnchor
Controls the frame of reference for
lineTranslation.The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This property is only applied to the style if
lineTranslationis non-nil. Otherwise, it is ignored.This attribute corresponds to the
line-translate-anchorlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLLineTranslationAnchorvalues - Any of the following constant string values:
map: The line is translated relative to the map.viewport: The line is translated relative to the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineTranslationAnchor;Swift
var lineTranslationAnchor: NSExpression! { get set } - Constant
-
lineWidth
Stroke thickness.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *lineWidth;Swift
var lineWidth: NSExpression! { get set } -
lineWidthTransition
The transition affecting any changes to this layer’s
lineWidthproperty.This property corresponds to the
line-width-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition lineWidthTransition;Swift
var lineWidthTransition: MGLTransition { get set }
MGLSymbolStyleLayer
@interface MGLSymbolStyleLayer : MGLVectorStyleLayer
An MGLSymbolStyleLayer is a style layer that renders icon and text labels at
points or along lines on the map.
Use a symbol style layer to configure the visual appearance of feature labels.
These features can come from vector tiles loaded by an
MGLVectorTileSource
object, or they can be MGLShape or
MGLFeature instances in an
MGLShapeSource or
MGLComputedShapeSource object.
You can access an existing symbol style layer using the
-[MGLStyle layerWithIdentifier:]
method if you know its identifier;
otherwise, find it using the
MGLStyle.layers
property. You can also create a
new symbol style layer and add it to the style using a method such as
-[MGLStyle addLayer:].
Related examples
See the Dynamically style interactive points and Use images to cluster point data examples learn how to style data on your map using this layer.
Example
let layer = MGLSymbolStyleLayer(identifier: "coffeeshops", source: pois)
layer.sourceLayerIdentifier = "pois"
layer.iconImageName = NSExpression(forConstantValue: "coffee")
layer.iconScale = NSExpression(forConstantValue: 0.5)
layer.text = NSExpression(forKeyPath: "name")
layer.textTranslation = NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: 10, dy: 0)))
layer.textJustification = NSExpression(forConstantValue: "left")
layer.textAnchor = NSExpression(forConstantValue: "left")
layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee")
mapView.style?.addLayer(layer)
-
-initWithIdentifier:source:
Returns a symbol style layer initialized with an identifier and source.
After initializing and configuring the style layer, add it to a map view’s style using the
-[MGLStyle addLayer:]or-[MGLStyle insertLayer:belowLayer:]method.Declaration
Objective-C
- (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier source:(nonnull MGLSource *)source;Swift
init(identifier: String, source: MGLSource)Parameters
identifierA string that uniquely identifies the source in the style to which it is added.
sourceThe source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.
Return Value
An initialized foreground style layer.
Accessing the Layout Attributes
-
iconAllowsOverlap
If true, the icon will be visible even if it collides with other previously drawn symbols.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.This attribute corresponds to the
icon-allow-overlaplayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconAllowsOverlap;Swift
var iconAllowsOverlap: NSExpression! { get set } -
iconAnchor
Part of the icon placed closest to the anchor.
The default value of this property is an expression that evaluates to
center. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLIconAnchorvalues - Any of the following constant string values:
center: The center of the icon is placed closest to the anchor.left: The left side of the icon is placed closest to the anchor.right: The right side of the icon is placed closest to the anchor.top: The top of the icon is placed closest to the anchor.bottom: The bottom of the icon is placed closest to the anchor.top-left: The top left corner of the icon is placed closest to the anchor.top-right: The top right corner of the icon is placed closest to the anchor.bottom-left: The bottom left corner of the icon is placed closest to the anchor.bottom-right: The bottom right corner of the icon is placed closest to the anchor.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconAnchor;Swift
var iconAnchor: NSExpression! { get set } - Constant
-
iconIgnoresPlacement
If true, other symbols can be visible even if they collide with the icon.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.This attribute corresponds to the
icon-ignore-placementlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconIgnoresPlacement;Swift
var iconIgnoresPlacement: NSExpression! { get set } -
iconImageName
Name of a style image to use for drawing an image background.
Use the
+[MGLStyle setImage:forName:]method to associate an image with a name that you can set this property to.Within a constant string value, a feature attribute name enclosed in curly braces (e.g.,
{token}) is replaced with the value of the named attribute. Tokens inside non-constant expressions are ignored; instead, usemgl_join:and key path expressions.This attribute corresponds to the
icon-imagelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant string values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Related examples
See the Use images to cluster point data example to learn how to dynamically set your icons with an expression.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconImageName;Swift
var iconImageName: NSExpression! { get set } -
iconOffset
Offset distance of icon from its anchor.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 rightward and 0 downward. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconOffset;Swift
var iconOffset: NSExpression! { get set } - Constant
-
iconOptional
If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil, andtextis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isIconOptional, null_resettable) NSExpression *iconOptional;Swift
var iconOptional: NSExpression! { get set } -
iconPadding
Size of the additional area around the icon bounding box used for detecting symbol collisions.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
2. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconPadding;Swift
var iconPadding: NSExpression! { get set } -
iconPitchAlignment
Orientation of icon when map is pitched.
The default value of this property is an expression that evaluates to
auto. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLIconPitchAlignmentvalues - Any of the following constant string values:
map: The icon is aligned to the plane of the map.viewport: The icon is aligned to the plane of the viewport.auto: Automatically matches the value oficon-rotation-alignment.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconPitchAlignment;Swift
var iconPitchAlignment: NSExpression! { get set } - Constant
-
iconRotation
Rotates the icon clockwise.
This property is measured in degrees.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.This attribute corresponds to the
icon-rotatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconRotation;Swift
var iconRotation: NSExpression! { get set } -
iconRotationAlignment
In combination with
symbolPlacement, determines the rotation behavior of icons.The default value of this property is an expression that evaluates to
auto. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLIconRotationAlignmentvalues - Any of the following constant string values:
map: Whensymbol-placementis set topoint, aligns icons east-west. Whensymbol-placementis set tolineorline-center, aligns icon x-axes with the line.viewport: Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value ofsymbol-placement.auto: Whensymbol-placementis set topoint, this is equivalent toviewport. Whensymbol-placementis set tolineorline-center, this is equivalent tomap.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconRotationAlignment;Swift
var iconRotationAlignment: NSExpression! { get set } - Constant
-
iconScale
Scales the original size of the icon by the provided factor. The new point size of the image will be the original point size multiplied by
iconScale. 1 is the original size; 3 triples the size of the image.This property is measured in factor of the original icon sizes.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.This attribute corresponds to the
icon-sizelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconScale;Swift
var iconScale: NSExpression! { get set } -
iconTextFit
The directions in which the icon stretches to fit around the text. If the icon image is a resizable image, the resizable areas may be stretched, while the cap insets are always drawn at the original scale.
The default value of this property is an expression that evaluates to
none. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil, andtextis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLIconTextFitvalues - Any of the following constant string values:
none: The icon is displayed at its intrinsic aspect ratio.width: The icon is scaled in the x-dimension to fit the width of the text.height: The icon is scaled in the y-dimension to fit the height of the text.both: The icon is scaled in both x- and y-dimensions.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconTextFit;Swift
var iconTextFit: NSExpression! { get set } - Constant
-
iconTextFitPadding
Size of the additional area added to dimensions determined by
iconTextFit.This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containingUIEdgeInsetsZero. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil, andtextis non-nil, andiconTextFitis set to an expression that evaluates toMGLIconTextFitBoth,MGLIconTextFitWidth, orMGLIconTextFitHeight. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIEdgeInsetsvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconTextFitPadding;Swift
var iconTextFitPadding: NSExpression! { get set } - Constant
-
keepsIconUpright
If true, the icon may be flipped to prevent it from being rendered upside-down.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil, andiconRotationAlignmentis set to an expression that evaluates tomap, andsymbolPlacementis set to an expression that evaluates to eitherMGLSymbolPlacementLineorMGLSymbolPlacementLineCenter. Otherwise, it is ignored.This attribute corresponds to the
icon-keep-uprightlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *keepsIconUpright;Swift
var keepsIconUpright: NSExpression! { get set } -
keepsTextUpright
If true, the text may be flipped vertically to prevent it from being rendered upside-down.
The default value of this property is an expression that evaluates to
YES. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil, andtextRotationAlignmentis set to an expression that evaluates tomap, andsymbolPlacementis set to an expression that evaluates to eitherMGLSymbolPlacementLineorMGLSymbolPlacementLineCenter. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *keepsTextUpright;Swift
var keepsTextUpright: NSExpression! { get set } -
maximumTextAngle
Maximum angle change between adjacent characters.
This property is measured in degrees.
The default value of this property is an expression that evaluates to the float
45. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil, andsymbolPlacementis set to an expression that evaluates to eitherMGLSymbolPlacementLineorMGLSymbolPlacementLineCenter. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *maximumTextAngle;Swift
var maximumTextAngle: NSExpression! { get set } -
maximumTextWidth
The maximum line width for text wrapping.
This property is measured in ems.
The default value of this property is an expression that evaluates to the float
10. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *maximumTextWidth;Swift
var maximumTextWidth: NSExpression! { get set } -
symbolAvoidsEdges
Whether symbols in this layer avoid colliding with symbols in adjacent tiles.
If this property is set to
true, symbols in this layer avoid crossing the edge of a tile. You should set this property totrueif the backing vector tiles don’t have enough padding to prevent collisions, or if this layer’ssymbolPlacementproperty is set toMGLSymbolPlacementPointbut this layer is above a symbol layer whosesymbolPlacementproperty is set toMGLSymbolPlacementLine. You do not need to enable this property to prevent clipped labels at tile boundaries.The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This attribute corresponds to the
symbol-avoid-edgeslayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *symbolAvoidsEdges;Swift
var symbolAvoidsEdges: NSExpression! { get set } -
symbolPlacement
Label placement relative to its geometry.
The default value of this property is an expression that evaluates to
point. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
MGLSymbolPlacementvalues - Any of the following constant string values:
point: The label is placed at the point where the geometry is located.line: The label is placed along the line of the geometry. Can only be used onLineStringandPolygongeometries.line-center: The label is placed at the center of the line of the geometry. Can only be used onLineStringandPolygongeometries. Note that a single feature in a vector tile may contain multiple line geometries.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *symbolPlacement;Swift
var symbolPlacement: NSExpression! { get set } - Constant
-
symbolSortKey
Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When
iconAllowsOverlaportextAllowsOverlapisfalse, features with a lower sort key will have priority during placement. WheniconAllowsOverlaportextAllowsOverlapis set toYES, features with a higher sort key will overlap over features with a lower sort key.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *symbolSortKey;Swift
var symbolSortKey: NSExpression! { get set } -
symbolSpacing
Distance between two symbol anchors.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
250. Set this property tonilto reset it to the default value.This property is only applied to the style if
symbolPlacementis set to an expression that evaluates toline. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 1
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *symbolSpacing;Swift
var symbolSpacing: NSExpression! { get set } -
symbolZOrder
Controls the order in which overlapping symbols in the same layer are rendered
The default value of this property is an expression that evaluates to
auto. Set this property tonilto reset it to the default value.You can set this property to an expression containing any of the following:
- Constant
MGLSymbolZOrdervalues - Any of the following constant string values:
auto: Ifsymbol-sort-keyis set, sort based on that. Otherwise sort symbols by their y-position relative to the viewport.viewport-y: Specify this z order if symbols’ appearance relies on lower features overlapping higher features. For example, symbols with a pin-like appearance would require this z order.source: Specify this z order if the order in which features appear in the source is significant.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *symbolZOrder;Swift
var symbolZOrder: NSExpression! { get set } - Constant
-
text
Value to use for a text label.
Within a constant string value, a feature attribute name enclosed in curly braces (e.g.,
{token}) is replaced with the value of the named attribute. Tokens inside non-constant expressions are ignored; instead, usemgl_join:and key path expressions.The default value of this property is an expression that evaluates to the empty string. Set this property to
nilto reset it to the default value.This attribute corresponds to the
text-fieldlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant string values
- Formatted expressions.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Related examples
See the Cluster point data and Use images to cluster point data to learn how to use an expression to set this attribute to the number of markers within a cluster.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *text;Swift
var text: NSExpression! { get set } -
textAllowsOverlap
If true, the text will be visible even if it collides with other previously drawn symbols.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textAllowsOverlap;Swift
var textAllowsOverlap: NSExpression! { get set } -
textAnchor
Part of the text placed closest to the anchor.
The default value of this property is an expression that evaluates to
center. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil, andtextVariableAnchoris set tonil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLTextAnchorvalues - Any of the following constant string values:
center: The center of the text is placed closest to the anchor.left: The left side of the text is placed closest to the anchor.right: The right side of the text is placed closest to the anchor.top: The top of the text is placed closest to the anchor.bottom: The bottom of the text is placed closest to the anchor.top-left: The top left corner of the text is placed closest to the anchor.top-right: The top right corner of the text is placed closest to the anchor.bottom-left: The bottom left corner of the text is placed closest to the anchor.bottom-right: The bottom right corner of the text is placed closest to the anchor.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textAnchor;Swift
var textAnchor: NSExpression! { get set } - Constant
-
textFontNames
An array of font face names used to display the text.
The first font named in the array is applied to the text. For each character in the text, if the first font lacks a glyph for the character, the next font is applied as a fallback, and so on.
See the “Customizing Fonts” guide for details on how this SDK chooses and renders fonts based on the value of this property.
The default value of this property is an expression that evaluates to the array
Open Sans Regular,Arial Unicode MS Regular. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant array values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textFontNames;Swift
var textFontNames: NSExpression! { get set } -
textFontSize
Font size.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
16. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textFontSize;Swift
var textFontSize: NSExpression! { get set } -
textIgnoresPlacement
If true, other symbols can be visible even if they collide with the text.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textIgnoresPlacement;Swift
var textIgnoresPlacement: NSExpression! { get set } -
textJustification
Text justification options.
The default value of this property is an expression that evaluates to
center. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLTextJustificationvalues - Any of the following constant string values:
auto: The text is aligned towards the anchor position.left: The text is aligned to the left.center: The text is centered.right: The text is aligned to the right.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textJustification;Swift
var textJustification: NSExpression! { get set } - Constant
-
textLetterSpacing
Text tracking amount.
This property is measured in ems.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textLetterSpacing;Swift
var textLetterSpacing: NSExpression! { get set } -
textLineHeight
Text leading value for multi-line text.
This property is measured in ems.
The default value of this property is an expression that evaluates to the float
1.2. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textLineHeight;Swift
var textLineHeight: NSExpression! { get set } -
textOffset
Offset distance of text from its anchor.
This property is measured in ems.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 ems rightward and 0 ems downward. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil, andtextRadialOffsetis set tonil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textOffset;Swift
var textOffset: NSExpression! { get set } - Constant
-
textOptional
If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.
The default value of this property is an expression that evaluates to
NO. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil, andiconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant Boolean values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isTextOptional, null_resettable) NSExpression *textOptional;Swift
var textOptional: NSExpression! { get set } -
textPadding
Size of the additional area around the text bounding box used for detecting symbol collisions.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
2. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textPadding;Swift
var textPadding: NSExpression! { get set } -
textPitchAlignment
Orientation of text when map is pitched.
The default value of this property is an expression that evaluates to
auto. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLTextPitchAlignmentvalues - Any of the following constant string values:
map: The text is aligned to the plane of the map.viewport: The text is aligned to the plane of the viewport.auto: Automatically matches the value oftext.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textPitchAlignment;Swift
var textPitchAlignment: NSExpression! { get set } - Constant
-
textRadialOffset
Radial offset of text, in the direction of the symbol’s anchor. Useful in combination with
textVariableAnchor, which defaults to using the two-dimensionaltextOffsetif present.This property is measured in ems.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textRadialOffset;Swift
var textRadialOffset: NSExpression! { get set } -
textRotation
Rotates the text clockwise.
This property is measured in degrees.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant numeric values
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textRotation;Swift
var textRotation: NSExpression! { get set } -
textRotationAlignment
In combination with
symbolPlacement, determines the rotation behavior of the individual glyphs forming the text.The default value of this property is an expression that evaluates to
auto. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLTextRotationAlignmentvalues - Any of the following constant string values:
map: Whensymbol-placementis set topoint, aligns text east-west. Whensymbol-placementis set tolineorline-center, aligns text x-axes with the line.viewport: Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value ofsymbol-placement.auto: Whensymbol-placementis set topoint, this is equivalent toviewport. Whensymbol-placementis set tolineorline-center, this is equivalent tomap.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textRotationAlignment;Swift
var textRotationAlignment: NSExpression! { get set } - Constant
-
textTransform
Specifies how to capitalize text.
The default value of this property is an expression that evaluates to
none. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLTextTransformvalues - Any of the following constant string values:
none: The text is not altered.uppercase: Forces all letters to be displayed in uppercase.lowercase: Forces all letters to be displayed in lowercase.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textTransform;Swift
var textTransform: NSExpression! { get set } - Constant
-
textVariableAnchor
To increase the chance of placing high-priority labels on the map, you can provide an array of
textAnchorlocations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. UsetextJustify: autoto choose justification based on anchor position. To apply an offset, use thetextRadialOffsetor the two-dimensionaltextOffset.This property is only applied to the style if
textis non-nil, andsymbolPlacementis set to an expression that evaluates to orMGLSymbolPlacementPoint. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLTextAnchorarray values - Constant array, in which each element is any of the following constant string
values:
center: The center of the text is placed closest to the anchor.left: The left side of the text is placed closest to the anchor.right: The right side of the text is placed closest to the anchor.top: The top of the text is placed closest to the anchor.bottom: The bottom of the text is placed closest to the anchor.top-left: The top left corner of the text is placed closest to the anchor.top-right: The top right corner of the text is placed closest to the anchor.bottom-left: The bottom left corner of the text is placed closest to the anchor.bottom-right: The bottom right corner of the text is placed closest to the anchor.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textVariableAnchor;Swift
var textVariableAnchor: NSExpression! { get set } - Constant
-
textWritingModes
The property allows control over a symbol’s orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single ‘vertical’ enum value. The order of elements in an array define priority order for the placement of an orientation variant.
This property is only applied to the style if
textis non-nil, andsymbolPlacementis set to an expression that evaluates to orMGLSymbolPlacementPoint. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLTextWritingModearray values - Constant array, in which each element is any of the following constant string
values:
horizontal: If a text’s language supports horizontal writing mode, symbols with point placement would be laid out horizontally.vertical: If a text’s language supports vertical writing mode, symbols with point placement would be laid out vertically.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textWritingModes;Swift
var textWritingModes: NSExpression! { get set } - Constant
Accessing the Paint Attributes
-
iconColor
The tint color to apply to the icon. The
iconImageNameproperty must be set to a template image.The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconColor;Swift
var iconColor: NSExpression! { get set } - Constant
-
iconColorTransition
The transition affecting any changes to this layer’s
iconColorproperty.This property corresponds to the
icon-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition iconColorTransition;Swift
var iconColorTransition: MGLTransition { get set } -
iconHaloBlur
Fade out the halo towards the outside.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconHaloBlur;Swift
var iconHaloBlur: NSExpression! { get set } -
iconHaloBlurTransition
The transition affecting any changes to this layer’s
iconHaloBlurproperty.This property corresponds to the
icon-halo-blur-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition iconHaloBlurTransition;Swift
var iconHaloBlurTransition: MGLTransition { get set } -
iconHaloColor
The color of the icon’s halo. The
iconImageNameproperty must be set to a template image.The default value of this property is an expression that evaluates to
UIColor.clearColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconHaloColor;Swift
var iconHaloColor: NSExpression! { get set } - Constant
-
iconHaloColorTransition
The transition affecting any changes to this layer’s
iconHaloColorproperty.This property corresponds to the
icon-halo-color-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition iconHaloColorTransition;Swift
var iconHaloColorTransition: MGLTransition { get set } -
iconHaloWidth
Distance of halo to the icon outline.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconHaloWidth;Swift
var iconHaloWidth: NSExpression! { get set } -
iconHaloWidthTransition
The transition affecting any changes to this layer’s
iconHaloWidthproperty.This property corresponds to the
icon-halo-width-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition iconHaloWidthTransition;Swift
var iconHaloWidthTransition: MGLTransition { get set } -
iconOpacity
The opacity at which the icon will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconOpacity;Swift
var iconOpacity: NSExpression! { get set } -
iconOpacityTransition
The transition affecting any changes to this layer’s
iconOpacityproperty.This property corresponds to the
icon-opacity-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition iconOpacityTransition;Swift
var iconOpacityTransition: MGLTransition { get set } -
iconTranslation
Distance that the icon’s anchor is moved from its original placement.
This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 points rightward and 0 points downward. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil. Otherwise, it is ignored.This attribute corresponds to the
icon-translatelayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconTranslation;Swift
var iconTranslation: NSExpression! { get set } - Constant
-
iconTranslationTransition
The transition affecting any changes to this layer’s
iconTranslationproperty.This property corresponds to the
icon-translate-transitionproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition iconTranslationTransition;Swift
var iconTranslationTransition: MGLTransition { get set } -
iconTranslationAnchor
Controls the frame of reference for
iconTranslation.The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This property is only applied to the style if
iconImageNameis non-nil, andiconTranslationis non-nil. Otherwise, it is ignored.This attribute corresponds to the
icon-translate-anchorlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLIconTranslationAnchorvalues - Any of the following constant string values:
map: Icons are translated relative to the map.viewport: Icons are translated relative to the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *iconTranslationAnchor;Swift
var iconTranslationAnchor: NSExpression! { get set } - Constant
-
textColor
The color with which the text will be drawn.
The default value of this property is an expression that evaluates to
UIColor.blackColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textColor;Swift
var textColor: NSExpression! { get set } - Constant
-
textColorTransition
The transition affecting any changes to this layer’s
textColorproperty.This property corresponds to the
textproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition textColorTransition;Swift
var textColorTransition: MGLTransition { get set } -
textHaloBlur
The halo’s fadeout distance towards the outside.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textHaloBlur;Swift
var textHaloBlur: NSExpression! { get set } -
textHaloBlurTransition
The transition affecting any changes to this layer’s
textHaloBlurproperty.This property corresponds to the
textproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition textHaloBlurTransition;Swift
var textHaloBlurTransition: MGLTransition { get set } -
textHaloColor
The color of the text’s halo, which helps it stand out from backgrounds.
The default value of this property is an expression that evaluates to
UIColor.clearColor. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
UIColorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textHaloColor;Swift
var textHaloColor: NSExpression! { get set } - Constant
-
textHaloColorTransition
The transition affecting any changes to this layer’s
textHaloColorproperty.This property corresponds to the
textproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition textHaloColorTransition;Swift
var textHaloColorTransition: MGLTransition { get set } -
textHaloWidth
Distance of halo to the font outline. Max text halo width is ¼ of the font-size.
This property is measured in points.
The default value of this property is an expression that evaluates to the float
0. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values no less than 0
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textHaloWidth;Swift
var textHaloWidth: NSExpression! { get set } -
textHaloWidthTransition
The transition affecting any changes to this layer’s
textHaloWidthproperty.This property corresponds to the
textproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition textHaloWidthTransition;Swift
var textHaloWidthTransition: MGLTransition { get set } -
textOpacity
The opacity at which the text will be drawn.
The default value of this property is an expression that evaluates to the float
1. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant numeric values between 0 and 1 inclusive
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable and/or feature attributes
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textOpacity;Swift
var textOpacity: NSExpression! { get set } -
textOpacityTransition
The transition affecting any changes to this layer’s
textOpacityproperty.This property corresponds to the
textproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition textOpacityTransition;Swift
var textOpacityTransition: MGLTransition { get set } -
textTranslation
Distance that the text’s anchor is moved from its original placement.
This property is measured in points.
The default value of this property is an expression that evaluates to an
NSValueobject containing aCGVectorstruct set to 0 points rightward and 0 points downward. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
CGVectorvalues - Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Interpolation and step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation or step functions to feature attributes.
Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textTranslation;Swift
var textTranslation: NSExpression! { get set } - Constant
-
textTranslationTransition
The transition affecting any changes to this layer’s
textTranslationproperty.This property corresponds to the
textproperty in the style JSON file format.Declaration
Objective-C
@property (nonatomic) MGLTransition textTranslationTransition;Swift
var textTranslationTransition: MGLTransition { get set } -
textTranslationAnchor
Controls the frame of reference for
textTranslation.The default value of this property is an expression that evaluates to
map. Set this property tonilto reset it to the default value.This property is only applied to the style if
textis non-nil, andtextTranslationis non-nil. Otherwise, it is ignored.This attribute corresponds to the
textlayout property in the Mapbox Style Specification.You can set this property to an expression containing any of the following:
- Constant
MGLTextTranslationAnchorvalues - Any of the following constant string values:
map: The text is translated relative to the map.viewport: The text is translated relative to the viewport.
- Predefined functions, including mathematical and string operators
- Conditional expressions
- Variable assignments and references to assigned variables
- Step functions applied to the
$zoomLevelvariable
This property does not support applying interpolation functions to the
$zoomLevelvariable or applying interpolation or step functions to feature attributes.Declaration
Objective-C
@property (nonatomic, null_resettable) NSExpression *textTranslationAnchor;Swift
var textTranslationAnchor: NSExpression! { get set } - Constant